package leetcode.primary;

import utils.tree.TreeNode;

public class T101 {
    public boolean isSymmetric(TreeNode root) {
        if (root==null){
            return true;
        }else {
            return DFS(root.left,root.right);
        }
    }

    boolean DFS(TreeNode node1,TreeNode node2){
        if (node1==null && node2==null){
            return true;
        }

        if (node1==null || node2==null){
            return false;
        }

        if (node1.val==node2.val){
            boolean b1 = DFS(node1.left, node2.right);
            boolean b2 = DFS(node1.right,node2.left);
            return (b1&&b2);
        }else {
            return false;
        }
    }

    public static void main(String[] args) {
//        T101 t101 = new T101();
//        Tree tree = new BinaryTree(new char[]{'2','3','4','#','#','5','#','#','3','#','4','#','#'});
//        TreeNode root = tree.InitTree();
//        tree.InorderTravel(root);
//        System.out.println(t101.isSymmetric(root));
    }
}
